package homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;

public class Test08 {
	static String[] color={"红桃","方块","梅花","黑桃"}; 
	static String[] number={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
	static ArrayList<String> poker = new ArrayList<String>();
	static ArrayList<String> showPoker = new ArrayList<String>();
	static ArrayList<Integer> userPoker = new ArrayList<Integer>();
	static HashMap<Integer,String> map =new HashMap<>();
	static Set<Integer> index = new HashSet<>();
	
	public static void main(String[] args) {

		pokerInit();
		System.out.println(useGet());
	}

	private static ArrayList<String> useGet() {
		Random rd = new Random();
		while(index.size() < 9){
			index.add(rd.nextInt(54));
		}
		Iterator<Integer> iterator = index.iterator();
		while (iterator.hasNext()) {
			userPoker.add(iterator.next());
		}
		Collections.sort(userPoker);
		for(int idx:userPoker){
			showPoker.add(map.get(idx));
		}
		return showPoker;
	}

	private static void setHash() {
		for(int i=0;i<poker.size();i++){
			String str = poker.get(i);
			map.put(i, str);
		}
	}

	private static void pokerInit() {
		for(String num:number){
			for(String cl:color){
				poker.add(cl+num);
			}
		}
		Collections.addAll(poker, "大王", "小王");
		setHash();
	}
}
